using System.Collections.ObjectModel;
using System.Linq;

namespace XmlStudio.DataLayer {
    /// <summary>
    /// Represents node's address.
    /// </summary>
    internal class Address : Collection<int> {
        /// <summary>
        /// Initializes a new instance of the <see cref="Address"/> class.
        /// </summary>
        public Address() {

        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Address"/> class.
        /// </summary>
        /// <param name="list">Collection to pass to the instance.</param>
        public Address(System.Collections.Generic.IList<int> list)
            : base(list) {
        }

        /// <summary>
        /// Gets the text representation of the address.
        /// </summary>
        string Text { get { return this.ToString(); } }

        /// <summary>
        /// Creates text representation of the address.
        /// </summary>
        /// <returns>String with address.</returns>
        public override string ToString() {
            var s = new string((Enumerable.Range(0, this.Count).Select(i => (this[i] + " "))).SelectMany(x => x).ToArray());
            return s;
        }
    }
}